import asyncio

from model.backtest import BackTest
from service import dataService
from service.strategyService import Movement

async def backTest():
    # backtest = BackTest()
    # backtest.broker.setCash(10000)
    # window = 14
    # period = '15'
    # code = '000421'
    # trade_days = await dataService.get_tradeDateList(window=window)
    # start_date = trade_days[0]
    # end_date = trade_days[-1]
    # # 获取时间窗口内的分时数据
    # _ ,df = await dataService.get_stockHistList(
    #     code=code,
    #     start_date=start_date,
    #     end_date=end_date,
    #     period=period
    # )
    # # 填充字段
    # backtest.setData(df)
    # model = Movement.IntradayMovementStrategy(period=period, window=window, code=code, rule=1)
    # backtest.setStrategy(model)
    # orderID, evaluate = await backtest.run()
    # print(orderID, evaluate)

    res = await dataService.get_tradeHistory('ORD92D6A0AEF9834F1D')
    print(res)  

if __name__ == '__main__':
    asyncio.run(backTest())
